package com.green.service.remote.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.green.common.util.TokenUtil;
import com.green.model.manage.JoinPackage;
import com.green.service.manage.JoinPackageService;
import com.green.service.remote.JoinPackageRemoteService;
import com.green.service.remote.model.Result;

@Component
public class JoinPackageRemoteServiceImpl implements JoinPackageRemoteService {
	@Resource
	private JoinPackageService joinPackageService;

	/**
	 * @param params
	 *            根据城市获取加盟套餐 参数名称 key limitCity 城市ID key joinType 店铺类型 token 令牌
	 * @param pagination
	 * @return
	 */
	@Override
	public Result<List<JoinPackage>> getJoinPackageList(
			Map<String, Object> param) {

		Result<List<JoinPackage>> result = new Result<List<JoinPackage>>();
		if (null != param && null != param.get("token")) {
			if (TokenUtil.validDefaultToken(param.get("token") + "")) {
				List<JoinPackage> list = joinPackageService
						.getJoinPackageList(param);
				if (list != null) {
					result.setSuccess(true);
					result.setData(list);
				} else {
					result.setSuccess(false);
					result.setMessage("查询不到加盟套餐");
				}
			} else {
				result.setSuccess(false);
				result.setMessage("内部无效令牌");
			}
		} else {
			result.setSuccess(false);
			result.setMessage("内部无效令牌");
		}
		return result;
	}

}
